package com.example.bill.glidedemo;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

import com.bumptech.glide.Glide;

public class MainActivity extends AppCompatActivity {

    ImageView imageView;
    Button btnLoadImg;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        imageView = (ImageView) findViewById(R.id.image_view);
        btnLoadImg = (Button)findViewById(R.id.btnLoadImg);

    }

    public void loadImage(View view) {
        String url = "https://ss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/logo/bd_logo1_31bdc765.png";
        /**
         * 使用Glide主要是这3步
         * 1.with
         *      关联activity fragment或者context的生命周期到下载任务里面
         * 2.load
         *      设置Request对象需要的资源链接
         * 3.into
         *      获取Request对象并绑定viewTarget -> 发起网络请求
         *
         * */
        Glide.with(this).load(url).into(imageView);
    }

}